package com.zqy.common;

/**
 * 异常编码
 */
public enum CommonErrorCode implements ErrorCode {
    //////////////////////////////////// 公用异常编码 //////////////////////////
    E_100101(100101, "传入参数与接口不匹配"),
    E_100102(100102, "验证码错误"),
    E_100103(100103, "验证码为空"),
    E_100104(100104, "查询结果为空"),
    E_100105(100105, "ID格式不正确或超出Long存储范围"),
    E_100106(100106, "上传错误"),
    E_100107(100107, "发送验证码错误"),
    E_100108(100108, "传入对象为空"),
    E_100109(100109, "手机号格式不正确"),
    E_100110(100110, "用户名为空"),
    E_100111(100111, "密码为空"),
    E_100112(100112, "手机号为空"),
    E_100113(100113, "手机号已存在"),
    E_100114(100114, "用户名已存在"),
    E_100115(100115, "密码不正确"),
    E_100116(100116, "导出excel异常"),
    E_100117(100116, "导出excel异常,模板列未定义"),
    E_100118(100116, "导出excel异常,查询多表使用自定义的语句"),
    E_100119(100117, "文件不可删除"),
    E_100120(100118, "可选字段为空"),
    E_100121(100121, "导入数据不能为空"),
    E_100122(100122,"存在关联项目，不能删除"),
    E_100123(100123,"排序号长度不合法"),
    E_100124(100124,"排序号不合法"),
    E_100125(100125,"所属单位不合法"),
    E_100126(100126,"所属部门不合法"),
    E_100127(100127,"专业分类不合法"),
    E_100128(100128,"电压等级不合法"),
    E_100129(100129,"问题分类不合法"),
    E_100130(100130,"未批复项目不能出库"),
    E_100131(100131, "导入模板不正确，请先下载正确的导入模板再完成导入"),
    E_100132(100132, "没有权限删除"),
    E_100133(100133, "导入失败，没有权限，只能导入本单位数据"),
    E_100134(100134, "用户没有专项"),
    E_100135(100135,"项目已经进入储备状态"),
    E_100136(100136,"项目已经批复"),
    E_100137(100137,"项目可研批复动态投资需要填写"),
    E_100138(100138,"批量打分需勾选相同专项项目"),
    E_100139(100139,"项目出库包含未批复项目"),
    E_100140(100140,"投资金额不足,没有可出库项目"),
    E_100141(100141,"该专项下没有可出库项目"),
    E_NO_AUTHORITY(999997, "没有访问权限"),
    CUSTOM(999998, "自定义异常"),
    E_200001(200001,"isc链接错误，请联系管理员"),
    E_200002(200002,"该用户没有权限，请联系管理员"),
    E_200003(200003,"该用户没有角色，请联系管理员"),
    E_200004(200004,"省公司没有编码权限"),
    /**
     * 未知错误
     */
    NO_CORE(500000, "缺少核心参数"),
    UNKNOWN(999999, "未知错误");

    private int code;
    private String desc;

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    private CommonErrorCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static CommonErrorCode setErrorCode(int code) {
        for (CommonErrorCode errorCode : CommonErrorCode.values()) {
            if (errorCode.getCode() == code) {
                return errorCode;
            }
        }
        return null;
    }
}
